<center><b><?php echo $program_name ?></b></center>
<br/>
<div>
    <form action="<?php echo url_for('program/export_certificates') ?>" target="_blank" method="post" onsubmit="return check_manager_name()">
    <input type=hidden name=id value="<?php echo $program_id ?>" />
    <div class="certificates_wrap">
        <table width="100%" border="0" dir="rtl">
            <tr>
                <th>
                    <?php echo __('Number') ?>
                </th>
                <th>
                    <?php echo __('Have Certificate') ?>
                </th>
                <th>
                    <?php echo __('Teacher Name') ?>
                </th>
                <th>
                    <?php echo __('School Name') ?>
                </th>
                <th>
                    <?php echo __('Absences') ?>
                </th>
                <th>
                    <?php echo __('Absence Rate') ?>
                </th>
            </tr>
            <?php foreach ($teachers as $k => $one) { ?>
                <?php $teacher = $one['Teacher'] ?>
                <?php $attendance = $teacher['Attendance'] ?>
                <?php $absences = count($attendance);  ?>
                <?php $absence_ratio = number_format($absences / $program_obj->getDurationDays() / 2 ,2) * 100;   ?>
                <?php $give_cert = $absence_ratio < 20 ? true : false ?>
                <tr <?php if( $give_cert ) echo 'class="green"' ?>>
                    <td>
                        <?php echo $k + 1 ?>
                    </td>
                    <td align="center">
                        <input type="checkbox" <?php if( $give_cert ) echo 'checked="checked"' ?> name="give_cert[<?php echo $teacher['intg_identity'] ?>]" />
                    </td>
                    <td>
                        <?php echo $teacher['f_name'] . ' ' . $teacher['s_name'] . ' ' . $teacher['t_name'] . ' ' . $teacher['l_name'] ?>
                    </td>
                    <td>
                        <?php $school = $teacher['School'] ?>
                        <?php echo $school['name'] ?>
                    </td>
                    <td>
                        <?php echo $absences ?>
                    </td>
                    <td>
                        <?php echo $absence_ratio  ?>%
                    </td>
                </tr>
            <?php } ?>
        </table>
		<div>
        <div class="certification_names_table"><?php echo __('manager_name') ?>
        <input id="manager_name" type="text" name="manager_name"/></div>		<div>
        <div class="certification_names_table"><?php echo __('center_name') ?>
        <input id="manager_name" type="text" name="center_name"/></div>
		</div>
        <br/>
        <br/>
        <b><?php echo __('Note') ?></b>:&nbsp;<?php echo __('give_certificate_note1') ?>&nbsp;<input type="checkbox" checked="checked" onclick="return false" />&nbsp;<?php echo __('give_certificate_note2') ?>
        
        <br/>
        <br/>
        <center>
            <button class="kts_button"><?php echo __('Print Certificates') ?></button>
        </center>
    </div>
    </form>
</div>

<script type="text/javascript">
    alert_text = 'يجب إدخال إسم مدير مركز التدريب';
    
    function check_manager_name(){
        manager_name_exists = document.getElementById('manager_name').value != ""
        if(!manager_name_exists) {
            jQuery('#manager_name').css('background-color','#FFCCCC');
            alert(alert_text);
        }
        return manager_name_exists;
    }
</script>